package com.Pounds.control;

import com.Pounds.pojo.Post;
import com.Pounds.pojo.User;
import com.Pounds.pojo.UserPrivacy;
import com.Pounds.service.UserService;
import org.apache.catalina.startup.UserConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("trane/user")
public class UserControl {

    @Autowired
    private UserService userService;

    @GetMapping("test")
    public List<User> findAll() {
        return userService.findAll();
    }

    @GetMapping("register")
    public String register(String username, String account, String password) {
        return userService.register(username,account,password);
    }

    @GetMapping("login")
    public String login(String account, String password) {
        return userService.login(account, password);
    }

    @GetMapping("info")
    public String getUserInfo(String userName) {
        return userService.getUserInfo(userName);
    }

    @GetMapping("privacy")
    public List<UserPrivacy> getUserPrivacy(String userName) {
        return userService.getUserPrivacy(userName);
    }

    @GetMapping("config")
    public List<UserConfig> getUserConfig(String userName) {
        return userService.getUserConfig(userName);
    }

    @GetMapping("other")
    public List<UserConfig> getOtherInfo(String userName) {
        return userService.getOtherInfo(userName);
    }
}
